package com.yuerlive.paperplane.timeline;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yuerlive.paperplane.R;

/**
 * Created by Admin on 2017/10/11.
 */

public class TimelineFragmentPagerAdapter extends FragmentPagerAdapter {
    private final int pageCount =3;
    private String[] titles;
    private ZhihuDailyFragment zhihuDailyFragment;
    private DoubanMomentFragment doubanMomentFragment;
    private GuokrHandpickFragment guokrHandpickFragment;
    public TimelineFragmentPagerAdapter(@NonNull FragmentManager fm,
                                        @NonNull Context context,@NonNull ZhihuDailyFragment zhihuDailyFragment,@NonNull DoubanMomentFragment doubanMomentFragment
    ,@NonNull GuokrHandpickFragment guokrHandpickFragment) {
        super(fm);
        titles =new String[]{context.getString(R.string.zhihu_daily),context.getString(R.string.douban_moment),context.getString(R.string.guokr_handpick)};
        this.zhihuDailyFragment=zhihuDailyFragment;
        this.doubanMomentFragment=doubanMomentFragment;
        this.guokrHandpickFragment=guokrHandpickFragment;

    }

    @Override
    public Fragment getItem(int position) {
        if(position==0){
            return zhihuDailyFragment;
        }else if(position==1){
            return  doubanMomentFragment;
        }else{
            return guokrHandpickFragment;
        }
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
